package com.dragon.sso.config;

import java.util.LinkedHashMap;
import java.util.Map;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;

/**
 * @author yanliang
 * @date 1/26/2021 1:53 PM
 */
public class CustomJwtAccessTokenConverter extends JwtAccessTokenConverter {

  @Override
  public OAuth2AccessToken enhance(
      OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
    //TODO 扩展属性
    Map<String, Object> additionalInformation = new LinkedHashMap<>();
    ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInformation);

    return super.enhance(accessToken, authentication);
  }
}
